home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / Softshoe / Lisa's Mac Parts / Files / Locations / Directory.h < prev    next >
Text File  |  2000-06-23  |  1KB  |  57 lines

  1. // Directory.h
  2.  
  3. #ifndef Directory_h
  4. #define Directory_h
  5.  
  6. #ifndef Volume_h
  7. #include "Volume.h"
  8. #endif
  9. #ifndef DirectoryID_h
  10. #include "DirectoryID.h"
  11. #endif
  12. #ifndef ConstPString_h
  13. #include "ConstPString.h"
  14. #endif
  15.  
  16. #include <Folders.h>
  17.  
  18. class FileLocation;
  19.  
  20. class Directory
  21.   {
  22.     private:
  23.         ::Volume volume;
  24.         DirectoryID id;
  25.         
  26.         static Directory FindSpecialFolder( OSType folder, ::Volume volume, bool canCreate );
  27.         
  28.         static ::Volume System()            { return ::Volume( kOnSystemDisk ); }
  29.         
  30.     public:
  31.         Directory( ::Volume theVolume, DirectoryID theID = DirectoryID::Root() )
  32.           : volume( theVolume ),
  33.              id( theID )
  34.           {}
  35.         
  36.         ::Volume Volume() const                        { return volume; }
  37.         DirectoryID ID() const                        { return id; }
  38.         
  39.         bool IsRoot() const                            { return id == DirectoryID::Root(); }
  40.         
  41.         void Up();
  42.         void Down( ConstPString );
  43.  
  44.         Directory Parent() const;
  45.         
  46.         bool operator==( Directory d ) const    { return volume == d.volume && id == d.id; }
  47.         bool operator!=( Directory d ) const    { return volume != d.volume || id != d.id; }
  48.         
  49.         static Directory Find( OSType folder, ::Volume volume = System() )
  50.             { return FindSpecialFolder( folder, volume, false ); }
  51.         
  52.         static Directory FindOrMake( OSType folder, ::Volume volume = System() )
  53.             { return FindSpecialFolder( folder, volume, true ); }
  54.   };
  55.  
  56. #endif
  57.